﻿namespace JshRCSWebApi.API.Utility.Autofac
{
    public class AutofacModule: Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            ////程序集诸如业务服务
            //var IApiServices = Assembly.Load("BaWei.RBAC.Repository");
            //var ApiServices = Assembly.Load("BaWei.RBAC.Service");
            ////根据名称约定(服务层的接口和实现均以Repositor;结尾)实现服务接口和服务实现的依赖 创建一个 0C 容器 把咱们获取的程序集存到里面
            //builder.RegisterAssemblyTypes(IApiServices).Where(t => t.Name.EndsWith("Repository")).AsImplementedInterfaces();
            ////根据名称约定(服务层的接口和实现以Service结尾),实现服务接口和服务实现的依赖
            //builder.RegisterAssemblyTypes(IApiServices).Where(t => t.Name.EndsWith("Services")).AsImplementedInterfaces();

            //把服务的注入规则写在这里
            //用于Jwt的各种操作
            builder.RegisterType<JwtSecurityTokenHandler>().InstancePerLifetimeScope();
            //自己写的支持泛型存入Jwt 便于扩展
            builder.RegisterType<JwtManager>().InstancePerLifetimeScope();

            //builder.RegisterType<TokenActionFilter>().InstancePerLifetimeScope();
            //builder.RegisterType<IHttpContextAccessor, HttpContextAccessor>().InstancePerLifetimeScope();
            //
        }
    }
}
